package dto

import (
	"tuowei.com/app/admin/models"
	"tuowei.com/common/dto"
	common "tuowei.com/common/models"
)

// SysAcademyGetPageReq 获取分页数据请求体
type SysAcademyGetPageReq struct {
	dto.Pagination `search:"-"`
	AcademyTitle   string `form:"academy_title" json:"academy_title" search:"type:contains;column:academy_title;table:sys_academy" comment:"文章标题"` // 文章标题
	AcademyStart   string `form:"beginTime" json:"beginTime" search:"type:gte;column:updated_at;table:sys_academy" comment:"开始日期"`                 // 开始日期
	AcademyEnd     string `form:"endTime" json:"endTime" search:"type:lte;column:updated_at;table:sys_academy" comment:"结束日期"`                     // 结束日期
	AcademyTop     string `form:"academy_top" json:"academy_top" search:"type:exact;column:academy_top;table:sys_academy" comment:"置顶文章"`          // 置顶文章
	//AcademyHot             string `json:"academy_hot" search:"type:exact;column:academy_hot;table:sys_academy" comment:"热门文章"`                        // 热门文章
	Province string `form:"province" json:"province" search:"type:contains;column:province;table:sys_academy" comment:"适用地区"`
}

func (m *SysAcademyGetPageReq) GetNeedSearch() interface{} {
	return *m
}

// SysAcademyInsertReq 新增请求体
type SysAcademyInsertReq struct {
	AcademyId           int    `json:"academy_id" comment:"文章ID"`           // 文章ID
	AcademyTitle        string `json:"academy_title" comment:"文章标题"`        // 文章标题
	WZUrl               string `json:"wz_url" comment:"文章封面url"`            // 文章封面url
	AcademyIntroduction string `json:"academy_introduction" comment:"文章描述"` // 文章描述
	AcademyContent      string `json:"academy_content" comment:"文章内容"`      // 文章内容
	AcademyTop          string `json:"academy_top" comment:"置顶文章"`          // 置顶文章
	AcademyHot          string `json:"academy_hot" comment:"热门文章"`          // 热门文章
	Province            string `json:"province" comment:"适用地区"`
	common.ControlBy
}

func (s *SysAcademyInsertReq) Generate(model *models.SysAcademy) {
	//model.CourseId = s.CourseId
	model.AcademyId = s.AcademyId
	model.AcademyTitle = s.AcademyTitle
	model.AcademyIntroduction = s.AcademyIntroduction
	model.AcademyContent = s.AcademyContent
	model.Province = s.Province
	model.WZUrl = s.WZUrl
	if s.AcademyTop != "1" {
		model.AcademyTop = "2"
	} else {
		model.AcademyTop = s.AcademyTop
	}
	if s.AcademyHot == "" {
		model.AcademyHot = "1"
	} else {
		model.AcademyHot = s.AcademyHot
	}
}

func (s *SysAcademyInsertReq) GetId() interface{} {
	return s.AcademyId
}

// SysAcademyUpdateReq 更新请求体
type SysAcademyUpdateReq struct {
	AcademyId           int    `json:"academy_id" comment:"文章ID"`           // 文章ID
	AcademyTitle        string `json:"academy_title" comment:"文章标题"`        // 文章标题
	WZUrl               string `json:"wz_url" comment:"文章封面url"`            // 文章封面url
	AcademyIntroduction string `json:"academy_introduction" comment:"文章描述"` // 文章描述
	AcademyContent      string `json:"academy_content" comment:"文章内容"`      // 文章内容
	AcademyTop          string `json:"academy_top" comment:"置顶文章"`          // 置顶文章
	AcademyHot          string `json:"academy_hot" comment:"热门文章"`          // 热门文章
	Province            string `json:"province" comment:"适用地区"`
	common.ControlBy
}

func (s *SysAcademyUpdateReq) Generate(model *models.SysAcademy) {
	if s.AcademyId != 0 {
		model.AcademyId = s.AcademyId
	}
	if s.AcademyTitle != "" {
		model.AcademyTitle = s.AcademyTitle
	}
	if s.WZUrl != "" {
		model.WZUrl = s.WZUrl
	}
	if s.AcademyIntroduction != "" {
		model.AcademyIntroduction = s.AcademyIntroduction
	}
	if s.AcademyContent != "" {
		model.AcademyContent = s.AcademyContent
	}
	if s.AcademyTop != "" {
		model.AcademyTop = s.AcademyTop
	}
	if s.AcademyHot != "" {
		model.AcademyHot = s.AcademyHot
	}
	if s.Province != "" {
		model.Province = s.Province
	}
	model.CreateBy = s.CreateBy
}

func (s *SysAcademyUpdateReq) GetId() interface{} {
	return s.AcademyId
}

type SysAcademyGetReq struct {
	Id int `uri:"id"`
}

func (s *SysAcademyGetReq) GetId() interface{} {
	return s.Id
}

// SysAcademyDeleteReq 删除请求体
type SysAcademyDeleteReq struct {
	Ids []int `json:"ids"`
}

func (s *SysAcademyDeleteReq) GetId() interface{} {
	return s.Ids
}
